package NBA

import org.apache.spark.SparkConf
import org.apache.spark.SparkContext
import org.apache.spark.SparkContext._

object ChamptionCountRDD {
  def main(args: Array[String]): Unit = {
    getChampionCount()
  }
  
  def getChampionCount():Unit = {
    // 实例化
    val conf = new SparkConf().setAppName("ChamptionCountRDD").setMaster("local")
    val sc = new SparkContext(conf)
    
    // 读取清理后的数据
    sc.textFile("A:/output3/nba_clear/part-00000")
    .map(_.split(","))
    .map(arr => (arr(2),1))
    .reduceByKey(_+_)
    .sortBy(t => t._2,false)
    .map(x => x._1 + "," + x._2)
    .foreach(println)
//    .repartition(1)
//    .saveAsTextFile("A:/output3/ChamptionCountRDD")
    
  }
  
}